<template>
  <view>

    <!-- 轮播图的区域 -->
    <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
      <swiper-item v-for="(item, i) in swiperList" :key="i">
        <image :src="item"></image>
      </swiper-item>
    </swiper>

    <!-- 分类导航区域 -->
    <view class="nav-list">
      <view class="nav-item" v-for="(item, i) in navList" :key="i" @click="navClickHandler(item)">
        <image :src="item.image_src" class="nav-img"></image>
        <text>woshi1</text>
      </view>
    </view>

    <!-- 楼层区域 -->
    <!-- 楼层的容器 -->
    <view class="floor-list">
      <!-- 每一个楼层的 item 项 -->
      <view class="floor-item" v-for="(item, i) in floorList" :key="i">
        <!-- 楼层的标题 -->
        <!-- <image :src="item.floor_title.image_src" class="floor-title"></image> -->
        <view class="text5">{{item.floor_title.name}}</view>
        <!-- 楼层的图片区域 -->
        <view class="floor-img-box">
          <!-- 左侧大图片的盒子 -->
          <navigator class="left-img-box" :url="item.product_list[0].url">
            <image :src="item.product_list[0].image_src" :style="{width: item.product_list[0].image_width + 'rpx'}"
              mode="widthFix"></image>
          </navigator>
          <!-- 右侧 4 个小图片的盒子 -->
          <view class="right-img-box">
            <navigator class="right-img-item" v-for="(item2, i2) in item.product_list" :key="i2" v-if="i2 !== 0"
              :url="item2.url">
              <image :src="item2.image_src" :style="{width: item2.image_width + 'rpx'}" mode="widthFix"></image>
            </navigator>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {

    data() {
      return {
        // 这是轮播图的数据列表
        swiperList: [],
        // 分类导航的数据列表
        navList: [],
        // 楼层的数据
        floorList: []
      };
    },
    onLoad() {
      // 调用方法，获取轮播图的数据
      this.getSwiperList()
      this.getNavList()
      this.getFloorList()
    },
    methods: {
      async getSwiperList() {


        this.swiperList = [
          "https://api-hmugo-web.itheima.net/pyg/banner1.png",
          "https://gimg3.baidu.com/topone/src=https%3A%2F%2Fbkimg.cdn.bcebos.com%2Fsmart%2F0bd162d9f2d3572c11df20db0f45742762d0f7036527-bkimg-process%2Cv_1%2Crw_1%2Crh_1%2Cmaxl_800%2Cpad_1%3Fx-bce-process%3Dimage%2Fresize%2Cm_pad%2Cw_348%2Ch_348%2Ccolor_ffffff&refer=http%3A%2F%2Fwww.baidu.com&app=2011&size=f200,200&n=0&g=0n&er=404&q=75&fmt=auto&maxorilen2heic=2000000?sec=1716656400&t=f01783d0e8d16f66e0ff3f484883d2e6",
          "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/liuliu.jpg",
          "https://api-hmugo-web.itheima.net/pyg/banner3.png"
        ]
      },
      async getNavList() {

        this.navList = [{
            "name": "第一",
            "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_4@2x.png",
            "open_type": "switchTab",
            "navigator_url": "/pages/category/main"
          },
          {
            "name": "第二",
            "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_3@2x.png"
          },
          {
            "name": "第三",
            "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_2@2x.png"
          },
          {
            "name": "第四",
            "image_src": "https://api-hmugo-web.itheima.net/pyg/icon_index_nav_1@2x.png"
          }
        ]
      },
      navClickHandler(item) {
        if (item.name === '分类') {
          uni.switchTab({
            url: '/pages/love/love'
          })
        }
      },
      // 获取首页楼层数据的方法
      async getFloorList() {

        this.floorList = [{
          "floor_title": {
            "name": "时尚11女装",
            "image_src": "https://api-hmugo-web.itheima.net/pyg/pic_floor01_title.png"
          },
          "product_list": [{
            "name": "优质服饰",
            "image_src": "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/xinxin/p6.jpg",
            "image_width": "232",
            "open_type": "navigate",
            "navigator_url": "/pages/goods_list?query=服饰"
          }, {
            "name": "春季热门",
            "image_src": "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/xinxin/p1.jpg",
            "image_width": "233",
            "open_type": "navigate",
            "navigator_url": "/pages/goods_list?query=热"
          }, {
            "name": "爆款清仓",
            "image_src": "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/xinxin/p2.jpg",
            "image_width": "233",
            "open_type": "navigate",
            "navigator_url": "/pages/goods_list?query=爆款"
          }, {
            "name": "倒春寒",
            "image_src": "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/xinxin/p3.jpg",
            "image_width": "233",
            "open_type": "navigate",
            "navigator_url": "/pages/goods_list?query=春季"
          }, {
            "name": "怦然心动",
            "image_src": "https://liuliu-gulimall.oss-cn-beijing.aliyuncs.com/xinxin/p4.jpg",
            "image_width": "233",
            "open_type": "navigate",
            "navigator_url": "/pages/goods_list?query=心动"
          }]
        }]
      }
    }
  }
</script>

<style lang="scss">
  swiper {
    height: 360rpx;

    .swiper-item,
    image {
      width: 100%;
      height: 100%;
    }
  }

  .nav-list {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;

    .nav-img {
      width: 128rpx;
      height: 140rpx;
    }
  }

  .floor-title {
    width: 100%;
    height: 60rpx;
  }

  .right-img-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
  }

  .floor-img-box {
    display: flex;
    padding-left: 10rpx;
     height: 260rpx;
  }

  .search-box {
    // 设置定位效果为“吸顶”
    position: sticky;
    // 吸顶的“位置”
    top: 0;
    // 提高层级，防止被轮播图覆盖
    z-index: 999;
  }
  .text5 {
      // position: absolute;
      left: 0px;
      // top: 460px;
      font-family: "΢���ź�";
      font-size: 16px;
      color: #559664;
      -webkit-box-reflect: below -3px -webkit-gradient(linear, 0 0, 0 100%, from(transparent), to(red));
  }

</style>